﻿using System;
using System.IO;
using iTextSharp.text.pdf;
using iTextSharp.text;

namespace ParadiseSuperMarket.Models
{
    public class PDFGenerator
    {
        public static void GeneratePDF()
        {
            //string[] dates = new string[]();
            Document document = new Document();
            try
            {
                string path = @"D:\report.pdf";
                PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create));
                document.Open();
                PdfPTable table = new PdfPTable(5);
                PdfPCell header = new PdfPCell(new Phrase("Aggregated Sales Report", new Font(Font.FontFamily.TIMES_ROMAN, 10f, Font.BOLD)));
                header.Colspan = 5;
                header.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
                table.AddCell(header);

                /*foreach (var date in dates)
                {
                    PdfPCell subheader = new PdfPCell(new Phrase("Aggregated Sales Report", new Font(Font.FontFamily.TIMES_ROMAN, 10f, Font.BOLD)));
                }*/
                document.Add(table);
            }
            finally
            {
                document.Close();
            }
        }
    }
}